/*
 * StarFunction.h
 *
 *  Created on: 24/nov/2010
 *      Author: computer
 */

#ifndef STARFUNCTION_H_
#define STARFUNCTION_H_
#include "Function.h"
#include "Integer.h"
#include "Real.h"
#include "Rational.h"

class IIStarSimplify {
public:
	TreeExpression::Integer* operator()(TreeExpression::Integer* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Integer(a->getData()*b->getData());
	}
};

class FIStarSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Real(a->getData()*b->getData());
	}
};

class IFStarSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Integer* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real(a->getData()*b->getData());
	}
};

class FFStarSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real(a->getData()*b->getData());
	}
};

class RRStarSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Rational* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Rational(a->getNumerator()*b->getNumerator(), a->getDenominator()*b->getDenominator());
	}
};

class RFStarSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Rational* a, TreeExpression::Real* b) const {
		return new TreeExpression::Real((a->getNumerator()/(double)a->getDenominator())*b->getData());
	}
};

class RIStarSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Rational* a, TreeExpression::Integer* b) const {
		return new TreeExpression::Rational(a->getNumerator()*b->getData(),a->getDenominator());
	}
};

class IRStarSimplify {
public:
	TreeExpression::Rational* operator()(TreeExpression::Integer* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Rational(b->getNumerator()*a->getData(),b->getDenominator());
	}
};

class FRStarSimplify {
public:
	TreeExpression::Real* operator()(TreeExpression::Real* a, TreeExpression::Rational* b) const {
		return new TreeExpression::Real(a->getData()*b->getNumerator()/(double)b->getDenominator());
	}
};

#endif /* STARFUNCTION_H_ */
